﻿package plugin.newnotice
{
    import com.core.*;
    import flash.events.*;
    import flash.utils.*;
    import morn.core.components.*;
    import uiresource.newnotice.*;

    public class NewNoticeCtrl extends XingongnengUI
    {
        private var cfgyugao:Array;
        private var index:int;
        private var time:uint;
        private var btnarr:Array;

        public function NewNoticeCtrl()
        {
            return;
        }// end function

        override protected function initializeView() : void
        {
            var _loc_3:UrlImage = null;
            super.initializeView();
            this.cfgyugao = ConfigDictionary.data.yugao;
            var _loc_1:int = 1;
            while (_loc_1 <= 3)
            {
                
                this["yeqian" + _loc_1].url = "gongneng/ye.png";
                this["yeqian" + _loc_1].visible = false;
                _loc_1++;
            }
            this.btnarr = [];
            var _loc_2:int = 0;
            while (_loc_2 < (this.cfgyugao.length - 1))
            {
                
                _loc_3 = new UrlImage();
                _loc_3.url = "gongneng/ye.png";
                _loc_3.name = "" + _loc_2;
                this.addChild(_loc_3);
                _loc_3.x = 54 + _loc_2 * 30;
                _loc_3.y = 439;
                _loc_3.addEventListener(MouseEvent.CLICK, this.onclick);
                this.btnarr.push(_loc_3);
                _loc_2++;
            }
            this.btnarr[0].url = "gongneng/ye1.png";
            this.index = 1;
            tu.url = "gongneng/" + this.cfgyugao[this.index].imageid;
            this.addEvent();
            return;
        }// end function

        private function addEvent() : void
        {
            closeBtn.addEventListener(MouseEvent.CLICK, this.onclose);
            return;
        }// end function

        public function openRefresh() : void
        {
            if (this.time > 0)
            {
                clearInterval(this.time);
                this.time = 0;
            }
            this.time = setInterval(this.move, 3000);
            return;
        }// end function

        protected function onclose(event:MouseEvent) : void
        {
            this.close();
            return;
        }// end function

        public function close() : void
        {
            if (this.time > 0)
            {
                clearInterval(this.time);
                this.time = 0;
            }
            ModelProxy.change("plugin", "close", "newnotice");
            return;
        }// end function

        protected function onclick(event:MouseEvent) : void
        {
            var _loc_2:* = event.currentTarget as UrlImage;
            this.index = int(_loc_2.name);
            var _loc_3:int = 0;
            while (_loc_3 < this.btnarr.length)
            {
                
                this.btnarr[_loc_3].url = "gongneng/ye.png";
                _loc_3++;
            }
            tu.url = "gongneng/" + this.cfgyugao[(this.index + 1)].imageid;
            this.btnarr[this.index].url = "gongneng/ye1.png";
            return;
        }// end function

        private function move() : void
        {
            var _loc_2:String = this;
            var _loc_3:* = this.index + 1;
            _loc_2.index = _loc_3;
            if (this.index >= this.btnarr.length)
            {
                this.index = 0;
            }
            var _loc_1:int = 0;
            while (_loc_1 < this.btnarr.length)
            {
                
                this.btnarr[_loc_1].url = "gongneng/ye.png";
                _loc_1++;
            }
            tu.url = "gongneng/" + this.cfgyugao[(this.index + 1)].imageid;
            this.btnarr[this.index].url = "gongneng/ye1.png";
            return;
        }// end function

    }
}
